#include<iostream>
#include<vector>
#include<algorithm>
template<typename T>
class D{ // 静态多态 模板
    public:
        D(T a){
            std::cout << "D constructor called with value: " << a << std::endl;
        }
        ~D(){
            std::cout << "D destructor called" << std::endl;
        }
        virtual void display(){
            std::cout << "D display function called" << std::endl;
        }
};
// 动态多态 虚函数
class A{
    public:
        A(int a){
            std::cout << "A constructor called with value: " << a << std::endl;
        }
        ~A(){
            std::cout << "A destructor called" << std::endl;
        }
        virtual void display(){
            std::cout << "A display function called" << std::endl;
        }
};
class B:public A{
    public:
        B(int a):A(a){
            std::cout << "B constructor called" << std::endl;
        }
        void display()override{
            std::cout << "B display function called" << std::endl;
        }
};
class C:public A{
    public:
        C(int a):A(a){
            std::cout << "C constructor called" << std::endl;
        }
        void display()override{
            std::cout << "C display function called" << std::endl;
        }
};
int main(){
    A a(10);
    A* b = new B(20);
    A* c = new C(30);
    D<float> d(3.14);
    D<int> e(3);
    a.display();
    b->display();
    c->display();
    d.display();
    e.display();
    std::vector<int> nums={1,3,6,8,2,4,6,9};
    std::sort(nums.begin(),nums.end(),[=](int a, int b){
        return a>b?a:b;
    });
    return 0;
}